using Unity.VisualScripting;
using GameFramework.Localization;

namespace LS.UGFUnits
{
    [UnitSurtitle("Localization Property")]
    [UnitShortTitle("Get")]
    public sealed class GetLocalizationProperty : LocalizationUnit
    {
        [DoNotSerialize]
        public ValueOutput Language { get; private set; }

        [DoNotSerialize]
        public ValueOutput SystemLanguage { get; private set; }
        
        [DoNotSerialize]
        public ValueOutput DictionaryCount { get; private set; }
        
        [DoNotSerialize]
        public ValueOutput CachedBytesSize { get; private set; }
        
        protected override void Definition()
        {
            Language = ValueOutput<Language>(nameof(Language));
            SystemLanguage = ValueOutput<Language>(nameof(SystemLanguage));
            DictionaryCount = ValueOutput<int>(nameof(DictionaryCount));
            CachedBytesSize = ValueOutput<int>(nameof(CachedBytesSize));
        }
        
        protected override ControlOutput In(Flow flow)
        {
            flow.SetValue(Language, Target?.Language ?? GameFramework.Localization.Language.Unspecified);
            flow.SetValue(SystemLanguage, Target?.SystemLanguage ?? GameFramework.Localization.Language.Unspecified);
            flow.SetValue(DictionaryCount, Target?.DictionaryCount ?? 0);
            flow.SetValue(CachedBytesSize, Target?.CachedBytesSize ?? 0);
            return base.In(flow);
        }
    }
}